from myelin.server.nodetype.Transform import TransformMap
from nodetypes.formats.mml.Events import CancelEventHandler

from MML import EventsTransform

from libhtml import reset, \
    commit

class EventsTransform(EventsTransform):
    
    chain = [
        TransformMap((
            '%(xslt-base-uri)sformats/html/%(app-key)s/layout-%(method)s.xslt',
            '%(xslt-base-uri)sformats/html/%(app-key)s/guest-account/preferences.xslt',
            '%(xslt-base-uri)sformats/html/%(app-key)s/base.xslt',                           
            ), (
            '%(i18n-common-base-uri)sformats/html/%(app-key)s/guest-account/preferences.xml',
            '%(i18n-theme-base-uri)sformats/html/%(app-key)s/guest-account/preferences.xml',
            )
        ),
    ]
    
    events = ({
        'reset'                 : (reset.EventHandler, {
            None                : chain,
            'user-redirect'     : None,
        }),
        'commit'                : (commit.EventHandler, {
            None                : chain,
            'user-redirect'     : None,
        }),
        'cancel'                : (CancelEventHandler, {
            None                : None,
        }),
        },
    )
    
    submitEvents = (
        ('commit','cancel',),
    )
    
del TransformMap, CancelEventHandler, reset, commit